import { defineStore } from 'pinia';
import type { ContentElement, dataType } from '@/api/class';
import { reqClassDataList, reqVideoList } from '@/api/class';
interface stateType {
  filterList: dataType[];
  videoList: ContentElement[];
  pageSize: number;
  pageNum: number;
}
const useClassStore = defineStore('class', {
  state: (): stateType => {
    return {
      filterList: [],
      videoList: [],
      pageSize: 20,
      pageNum: 0,
    };
  },
  actions: {
    //获取选项列表
    async getFilterList() {
      try {
        const result = await reqClassDataList();
        this.filterList = result;
      } catch (err) {
        return Promise.reject(err);
      }
    },
    //获取视频列表数据
    async getVideoList() {
      try {
        const result = await reqVideoList(this.pageSize, this.pageNum);
        this.videoList = result.content.content;
      } catch (err) {
        return Promise.reject(err);
      }
    },
  },
});
export default useClassStore;
